<?php
@session_start();
if(isset($_SESSION['user'])) {
    header("Location: index.php");
}
require 'template/header.php';
?>

<div id="container">
    <div id="left-panel">
        <div class="left-stuff">
            <h3>DANH MỤC SẢN PHẨM</h3>
            <ul id="left-menu">
                <li><a href="#">Bếp gas dương</a>
                    <ul class="list-menu">
                        <li><a href="#">Menu #1</a></li>
                        <li><a href="#">Menu #2</a></li>
                        <li><a href="#">Menu #3</a></li>
                        <li><a href="#">Menu #4</a></li>
                        <li><a href="#">Menu #5</a></li>
                    </ul>
                </li>
                <li><a href="#">Bếp gas âm</a>
                    <ul class="list-menu">
                        <li><a href="#">Menu #1</a></li>
                        <li><a href="#">Menu #2</a></li>
                        <li><a href="#">Menu #3</a></li>
                        <li><a href="#">Menu #4</a></li>
                        <li><a href="#">Menu #5</a></li>
                    </ul>
                </li>
                <li><a href="#">Máy hút khử mùi</a></li>
                <li><a href="#">Bếp điện từ</a></li>
                <li><a href="#">Chậu rửa bát</a></li>
                <li><a href="#">Bếp gas âm</a></li>
                <li><a href="#">Máy hút khử mùi</a></li>
                <li><a href="#">Bếp điện từ</a></li>
                <li><a href="#">Chậu rửa bát</a></li>
                <li><a href="#">Bếp gas âm</a></li>
                <li><a href="#">Máy hút khử mùi</a></li>
                <li><a href="#">Bếp điện từ</a></li>
                <li><a href="#">Chậu rửa bát</a></li>
                <li><a href="#">Bếp gas âm</a></li>
                <li><a href="#">Máy hút khử mùi</a></li>
                <li><a href="#">Bếp điện từ</a></li>
                <li><a href="#">Chậu rửa bát</a>
                    <ul class="list-menu">
                        <li><a href="#">Menu #1</a></li>
                        <li><a href="#">Menu #2</a></li>
                        <li><a href="#">Menu #3</a></li>
                        <li><a href="#">Menu #4</a></li>
                        <li><a href="#">Menu #5</a></li>
                    </ul>
                </li>
            </ul>
        </div>	
    </div>

    <div id="content">
        <div class="log-reg">
            <h1>Đăng nhập</h1>
                <?php
                require './db.php';
                if (isset($_COOKIE['user'])) {
                ?>
                <form name="logForm" action="admin/process.php" onsubmit="return validateLogForm();" method="post">
                    <fieldset>
                        <p>
                            <label>Địa chỉ Email:</label>
                            <input type="text" name="txtUser" id="username" class="inp" value="<?php echo $_COOKIE['user']; ?>" /><span class="mess" id="un-mess"></span>
                        </p>
                        <p>
                            <label>Mật khẩu:</label>
                            <input type="password" name="txtPass" id="password" class="inp" value="<?php echo $_COOKIE['pass']; ?>" /><span class="mess" id="pw-mess"></span>
                        </p>
                        <p>
                            <label></label>
                            <input type="checkbox" name="chkRemember" value="1" checked /> Nhớ mật khẩu
                        </p>
                        <p>
                            <label></label>
                            <input type="hidden" name="url" value="<?php echo getCurrentUrl(); ?>" />
                            <input type="submit" name="btnSubmit" value="Đăng nhập" />
                        </p>
                    </fieldset>
                </form>
                <?php
                } else {
                ?>
                <form name="logForm" action="admin/process.php" onsubmit="return validateLogForm();" method="post">
                    <fieldset>
                        <p>
                            <label>Tên đăng nhập:</label>
                            <input type="text" name="txtUser" id="username" class="inp" /><span class="mess" id="un-mess"></span>
                        </p>
                        <p>
                            <label>Mật khẩu:</label>
                            <input type="password" name="txtPass" id="password" class="inp" /><span class="mess" id="pw-mess"></span>
                        </p>
                        <p>
                            <label></label>
                            <input type="checkbox" name="chkRemember" value="1" checked /> Nhớ mật khẩu
                        </p>
                        <p>
                            <label></label>
                            <input type="hidden" name="url" value="<?php echo getCurrentUrl(); ?>" />
                            <input type="submit" name="btnSubmit" value="Đăng nhập" />
                        </p>
                    </fieldset>
                </form>
                <?php
                }
                ?>
            <br />
            <a href="#">Đăng ký</a> | <a href="forgot-password.php">Quên mật khẩu</a>
        </div>
    </div>
</div>

<?php
require 'template/footer.php';
?>